package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${cfg.queryPachage}.${entity}Query;
import ${cfg.pageVoPackage}.${entity}Vo;
import ${cfg.basePojoPackage}.dto.DeleteDto;
import ${cfg.addDtoPackage}.${entity}AddDto;
import ${cfg.updateDtoPackage}.${entity}UpdateDto;
import ${cfg.basePojoPackage}.vo.PageVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import java.util.List;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    /**
    * ${table.comment!}的分页查询
    *
    * @param query
    * @return
    */
    @Override
    public PageVo<${entity}Vo> queryPage(${entity}Query query) {
        // todo 其他业务逻辑
        // 开启分页查询
        PageHelper.startPage(query.getPageNum(), query.getPageSize());
        List<${entity}Vo> vos = getBaseMapper().queryAll(query);
        PageInfo<${entity}Vo> pageinfo = new PageInfo<>(vos);
        return new PageVo(pageinfo);
    }

    /**
    * 新增${table.comment!}
    *
    * @param addDto
    */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void save(${entity}AddDto addDto) {
        // todo 其他业务逻辑
        ${entity} addDo = new ${entity}();
        BeanUtil.copyProperties(addDto, addDo);
        this.save(addDo);
    }

    /**
    * 修改${table.comment!}
    *
    * @param updateDto
    */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void update(${entity}UpdateDto updateDto) {
        // todo 其他业务逻辑
        ${entity} updateDo = new ${entity}();
        BeanUtil.copyProperties(updateDto, updateDo);
        this.updateById(updateDo);
    }

    /**
    * 删除多条${table.comment!}
    *
    * @param deleteDto
    */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(DeleteDto deleteDto) {
        // todo 其他业务逻辑
        if (CollUtil.isEmpty(deleteDto.getIds())) {
            return;
        }
        this.removeByIds(deleteDto.getIds());
    }
}
</#if>
